; Music of Brainache (1987) (Codemasters) (Jon Paul Eldridge)
; Ripped by Megachur the 03/04/2009

; Need System Vectors

	write "BRAINACH.BIN"

music_date_rip	equ &0349
music_adr	equ &a100
first_theme	equ 0
last_theme	equ 3	; 0 -> 3

	read "music_header_v1_0.asm"

; #a3d4
; db " *** Music written and translated by Jon Paul Eldridge (15) *** "

.la107 equ $ + 7
.la100
	db #02,#03,#01,#02,#0d,#ff,#03,#01
.la10f equ $ + 7
.la10b equ $ + 3
	db #0f,#ff,#01,#01,#0f,#ff,#07,#01
.la113 equ $ + 3
	db #0f,#ff,#02,#02,#05,#01,#01,#0f
.la11e equ $ + 6
.la11a equ $ + 2
	db #ff,#08,#01,#0f,#ff,#0c,#01,#0f
	db #ff,#04
.la123 equ $+1
.la122
	ld a,#01
	call la1b1
	ld a,#01
	ld (la1a3),a
	ld hl,(la32b)
	ld (la32d),hl
	ld hl,(la33b)
	ld (la33d),hl
	ld hl,(la34b)
	ld (la34d),hl
	xor a
	ld (la32a),a
	ld (la330),a
	ld (la33a),a
	ld (la340),a
	ld (la34a),a
	ld (la350),a
	add #02
	ld (la32f),a
	ld (la33f),a
	ld (la34f),a
	ld hl,la100
	ld a,#01
	call #bcbc
	ld hl,la107
	ld a,#02
	call #bcbc
	ld hl,la10b
	ld a,#03
	call #bcbc
	ld hl,la10f
	ld a,#04
	call #bcbc
	ld hl,la113
	ld a,#05
	call #bcbc
	ld hl,la11a
	ld a,#06
	call #bcbc
	ld hl,la11e
	ld a,#07
	call #bcbc
	call #bca7
	ld hl,la351
	ld bc,#8100
	ld de,la20b
	jp #bcd7
.la1a3
	nop
.la1a4
	xor a
	ld (la1a3),a
	ld hl,la351
	call #bcdd
	jp #bca7
.la1b1
	cp #01
	jr z,la1bf
	cp #02
	jr z,la1d2
	cp #03
	jr z,la1e5
	jr la1f8
.la1bf
	ld hl,la414
	ld (la32b),hl
	ld hl,la43d
	ld (la33b),hl
	ld hl,la5a2
	ld (la34b),hl
	ret
.la1d2
	ld hl,la5c9
	ld (la32b),hl
	ld hl,la602
	ld (la33b),hl
	ld hl,la62d
	ld (la34b),hl
	ret
.la1e5
	ld hl,la64c
	ld (la32b),hl
	ld hl,la66b
	ld (la33b),hl
	ld hl,la6b4
	ld (la34b),hl
	ret
.la1f8
	ld hl,la6e5
	ld (la32b),hl
	ld hl,la722
	ld (la33b),hl
	ld hl,la747
	ld (la34b),hl
	ret
;
.play_music
.la20b
;
	push af
	push iy
	ld a,(la32f)
	sub #02
	ld (la32f),a
	ld iy,la321
	call z,la23f
	ld a,(la33f)
	sub #02
	ld (la33f),a
	ld iy,la331
	call z,la23f
	ld a,(la34f)
	sub #02
	ld (la34f),a
	ld iy,la341
	call z,la23f
	pop iy
	pop af
	ret
.la23f
	push bc
	push de
	push hl
	push ix
.la244
	ld l,(iy+#0c)
	ld h,(iy+#0d)
	push hl
	pop ix
.la24d
	ld a,(ix+#00)
	cp #ff
	jr z,la2bf
	cp #fe
	jr z,la2d7
	cp #fd
	jp z,la2e7
	cp #fc
	jr z,la2df
	cp #fb
	jr z,la2ce
	cp #fa
	jp z,la2ef
	cp #7f
	jp nc,la2f7
	ld hl,la35a
	ld a,(ix+#00)
	sla a
	ld b,#00
	ld c,a
	add hl,bc
	ld a,(hl)
	ld (iy+#03),a
	inc hl
	ld a,(hl)
	ld (iy+#04),a
	ld a,(ix+#01)
	ld (iy+#07),a
	ld (iy+#0e),a
	ld l,(iy+#0c)
	ld h,(iy+#0d)
	inc hl
	inc hl
	ld (iy+#0c),l
	ld (iy+#0d),h
	push iy
	pop hl
	call #bcaa
	pop ix
	pop hl
	pop de
	pop bc
	ret
	xor a
	ld (iy+#09),a
.la2ab
	ld l,(iy+#0c)
	ld h,(iy+#0d)
	inc hl
	inc hl
	inc ix
	inc ix
	ld (iy+#0c),l
	ld (iy+#0d),h
	jr la24d
.la2bf
	ld a,(iy+#0a)
	ld (iy+#0c),a
	ld a,(iy+#0b)
	ld (iy+#0d),a
	jp la244
.la2ce
	ld a,(ix+#01)
	ld (iy+#05),a
	jp la2ab
.la2d7
	ld a,(ix+#01)
	ld (iy+#01),a
	jr la2ab
.la2df
	ld a,(ix+#01)
	ld (iy+#02),a
	jr la2ab
.la2e7
	ld a,(ix+#01)
	ld (iy+#06),a
	jr la2ab
.la2ef
	pop ix
	pop hl
	pop de
	pop bc
	jp la1a4
.la2f7
	ld b,a
	ld a,(iy+#09)
	cp #00
	jr nz,la302
	ld a,b
	sub #7f
.la302
	dec a
	ld (iy+#09),a
	cp #00
	jr z,la2ab
	ld a,(ix+#01)
	sla a
	ld b,#00
	ld c,a
	and a
	push ix
	pop hl
	sbc hl,bc
	ld (iy+#0c),l
	ld (iy+#0d),h
	jp la244
.la321
	db #01,#00,#00,#00,#00,#00,#00,#00
	db #00
.la32a
	db #00
.la32d equ $ + 2
.la32b
	db #00,#00,#00,#00
.la331 equ $ + 2
.la330 equ $ + 1
.la32f
	db #02,#00,#02,#00,#00,#00,#00,#00
.la33a equ $ + 3
	db #00,#00,#00,#00
.la33d equ $ + 2
.la33b
	db #00,#00,#00,#00
.la341 equ $ + 2
.la340 equ $ + 1
.la33f
	db #02,#00,#04,#00,#00,#00,#00,#00
.la34a equ $ + 3
	db #00,#00,#00,#00
.la34d equ $ + 2
.la34b
	db #00,#00,#00,#00
.la351 equ $ + 2
.la350 equ $ + 1
.la34f
	db #02,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00
.la35a
	dw #03bc,#0386,#0353,#0324
	dw #02f6,#02cc,#02a4,#027e
	dw #025a,#0238,#0218,#01fa
	dw #01de,#01c3,#01aa,#0192
	dw #017b,#0166,#0152,#013f
	dw #012d,#011c,#010c,#00fd
	dw #00ef,#00e1,#00d5,#00c9
	dw #00be,#00b3,#00a9,#009f
	dw #0096,#008e,#0086,#007f
	dw #0077,#0071,#006a,#0064
	dw #005f,#0059,#0054,#0050
	dw #004b,#0047,#0043,#003f
	dw #003c,#0038,#0035,#0032
	dw #002f,#002d,#002a,#0028
	dw #0026,#0024,#0022,#0020
	dw #0000
	db #20,#2a,#2a,#2a,#20,#4d,#75,#73
	db #69,#63,#20,#77,#72,#69,#74,#74
	db #65,#6e,#20,#61,#6e,#64,#20,#74
	db #72,#61,#6e,#73,#6c,#61,#74,#65
	db #64,#20,#62,#79,#20,#4a,#6f,#6e
	db #20,#50,#61,#75,#6c,#20,#45,#6c
	db #64,#72,#69,#64,#67,#65,#20,#28
	db #31,#35,#29,#20,#2a,#2a,#2a,#20
.la414
	db #fc,#00,#fb,#00,#fe,#01,#fd,#0c
	db #0e,#20,#0e,#10,#0e,#08,#0e,#08
	db #0c,#10,#09,#10,#0c,#10,#0e,#20
	db #0e,#20,#0e,#08,#0e,#08,#10,#10
	db #11,#10,#10,#10,#11,#10,#9b,#0f
.la43d equ $ + 1
	db #ff,#fe,#00,#fd,#00,#00,#80,#00
	db #80,#00,#80,#00,#80,#fe,#03,#fd
	db #0f,#fc,#00,#fb,#00,#21,#10,#21
	db #10,#1d,#10,#1f,#20,#1f,#10,#1a
	db #20,#21,#10,#21,#10,#1d,#10,#1f
	db #20,#1f,#10,#1a,#10,#1a,#10,#81
	db #0d,#21,#10,#21,#10,#1f,#10,#1d
	db #10,#1f,#20,#1d,#10,#1a,#50,#1d
	db #20,#1f,#20,#21,#10,#21,#10,#1f
	db #10,#1d,#10,#1f,#20,#1d,#10,#1a
	db #50,#1d,#20,#1f,#20,#21,#20,#21
	db #10,#1f,#10,#1d,#10,#1f,#20,#21
	db #10,#21,#10,#21,#10,#1f,#10,#1d
	db #10,#1f,#20,#1a,#20,#21,#20,#21
	db #20,#1d,#10,#1f,#20,#21,#10,#21
	db #10,#21,#10,#1f,#10,#1d,#10,#1f
	db #20,#1a,#20,#1a,#20,#1a,#10,#1a
	db #08,#1a,#08,#18,#10,#15,#10,#18
	db #10,#1a,#20,#1a,#20,#1a,#08,#1a
	db #08,#1c,#10,#1d,#10,#1c,#10,#1d
	db #10,#81,#0f,#21,#40,#1f,#10,#1d
	db #10,#1f,#10,#1a,#40,#1a,#10,#1d
	db #10,#1a,#10,#1f,#10,#1a,#10,#81
	db #0a,#21,#20,#21,#20,#1f,#10,#1d
	db #10,#1f,#10,#1a,#40,#1a,#10,#1d
	db #10,#1a,#10,#1f,#10,#1a,#10,#81
	db #0b,#fd,#00,#fe,#00,#00,#80,#00
	db #80,#00,#80,#00,#80,#fe,#03,#fd
	db #0f,#1a,#10,#18,#10,#15,#30,#15
	db #10,#18,#10,#1a,#50,#1c,#20,#1d
	db #20,#1a,#10,#18,#10,#15,#30,#15
	db #10,#18,#10,#1a,#50,#1d,#20,#1c
	db #20,#81,#10,#1a,#20,#1a,#10,#1a
	db #08,#1a,#08,#18,#10,#15,#10,#18
	db #10,#1a,#20,#1a,#20,#1a,#08,#1a
	db #08,#1c,#10,#1d,#10,#1c,#10,#1d
	db #10,#81,#0f,#fd,#0f,#fe,#04,#1a
	db #20,#26,#10,#1a,#20,#1a,#30,#1a
	db #20,#26,#10,#1a,#20,#1a,#10,#26
	db #20,#1a,#20,#26,#10,#1a,#20,#1a
	db #30,#1a,#20,#26,#10,#1a,#10,#1a
	db #10,#1a,#10,#26,#20,#81,#13,#1d
	db #10,#1d,#10,#1c,#10,#1a,#50,#1d
	db #10,#1d,#10,#1c,#10,#1a,#20,#1a
.la5a2 equ $ + 6
	db #20,#1a,#10,#81,#0a,#ff,#fc,#00
	db #fd,#0f,#fb,#01,#fe,#02,#3c,#10
	db #3c,#10,#fb,#03,#fe,#04,#3c,#10
	db #fb,#01,#fe,#02,#3c,#10,#3c,#10
	db #3c,#10,#fe,#04,#fb,#03,#3c,#10
.la5c9 equ $ + 5
	db #3c,#10,#b7,#12,#ff,#fb,#00,#fc
	db #00,#fe,#00,#fd,#00,#00,#10,#fd
	db #0a,#fe,#05,#1d,#10,#21,#10,#24
	db #20,#1f,#10,#23,#10,#26,#20,#21
	db #10,#24,#10,#28,#10,#21,#20,#1f
	db #20,#1d,#10,#1d,#10,#1d,#20,#1f
	db #10,#1f,#10,#1f,#20,#21,#10,#21
.la602 equ $ + 6
	db #10,#1f,#10,#21,#40,#fa,#fb,#00
	db #fc,#00,#fd,#0f,#fe,#06,#11,#40
	db #13,#40,#15,#40,#15,#20,#13,#20
	db #fd,#0a,#fe,#05,#21,#10,#21,#10
	db #21,#20,#23,#10,#23,#10,#23,#20
	db #24,#10,#24,#10,#23,#10,#24,#40
.la62d equ $ + 1
	db #fa,#fb,#00,#fc,#00,#fd,#0f,#fe
	db #06,#05,#40,#07,#40,#09,#40,#09
	db #20,#07,#20,#05,#40,#07,#40,#09
	db #10,#09,#10,#07,#10,#09,#40,#fa
.la64c
	db #fc,#00,#fd,#0f,#fb,#01,#fe,#02
	db #3c,#20,#fe,#04,#3c,#10,#3c,#10
	db #fe,#02,#3c,#10,#3c,#10,#fe,#04
.la66b equ $ + 7
	db #3c,#10,#3c,#10,#83,#0b,#fa,#fb
	db #00,#fc,#00,#fd,#0f,#fe,#04,#00
	db #10,#0c,#10,#00,#10,#0c,#10,#02
	db #10,#0e,#10,#02,#10,#0e,#10,#04
	db #10,#10,#10,#04,#10,#10,#10,#04
	db #10,#10,#10,#04,#10,#10,#10,#00
	db #10,#0c,#10,#00,#10,#0c,#10,#02
	db #10,#0e,#10,#02,#10,#0e,#10,#00
	db #10,#0c,#10,#00,#10,#0c,#10,#00
	db #10,#0c,#10,#00,#10,#0c,#10,#fa
.la6b4
	db #fb,#00,#fc,#00,#fd,#0f,#fe,#07
	db #fb,#00,#fc,#00,#fd,#0f,#fe,#03
	db #18,#20,#1f,#20,#1c,#10,#1c,#10
	db #1f,#20,#18,#30,#1f,#10,#1c,#10
	db #1c,#10,#1f,#20,#18,#20,#1f,#20
	db #1d,#10,#1c,#10,#1a,#20,#18,#80
.la6e5 equ $ + 1
	db #fa,#fb,#00,#fc,#00,#fd,#0f,#fe
	db #07,#0c,#20,#0b,#10,#07,#20,#0c
	db #10,#0b,#10,#07,#10,#0c,#10,#0c
	db #10,#0b,#10,#07,#20,#0c,#10,#0b
	db #10,#07,#10,#0e,#20,#0c,#10,#09
	db #20,#0e,#10,#0c,#10,#09,#10,#0e
	db #10,#0e,#10,#0c,#10,#09,#20,#0e
.la722 equ $ + 6
	db #10,#0c,#10,#09,#10,#ff,#fc,#00
	db #fd,#0f,#fb,#01,#fe,#02,#3c,#10
	db #3c,#10,#fb,#06,#fe,#04,#3c,#20
	db #fb,#01,#fe,#02,#3c,#10,#3c,#10
	db #fb,#04,#fe,#04,#3c,#10,#3c,#10
.la747 equ $ + 3
	db #83,#0f,#ff,#fd,#0f,#fb,#00,#fe
	db #04,#18,#10,#18,#10,#24,#10,#18
	db #10,#18,#10,#24,#10,#18,#10,#24
	db #10,#81,#08,#1a,#10,#1a,#10,#26
	db #10,#1a,#10,#1a,#10,#26,#10,#1a
	db #10,#26,#10,#81,#08,#ff
	db #20,#2a,#2a,#20,#4d,#75,#73,#69
	db #63,#20,#77,#72,#69,#74,#74,#65
	db #6e,#20,#61,#6e,#64,#20,#74,#72
	db #61,#6e,#73,#6c,#61,#74,#65,#64
	db #20,#62,#79,#20,#4a,#6f,#6e,#20
	db #50,#61,#75,#6c,#20,#45,#6c,#64
	db #72,#69,#64,#67,#65,#20,#2a,#2a
	db #20,#00
;
.init_music	; 0 -> 3
;
	push af
	call la1a4
	pop af
	ld hl,la123
	ld (hl),a
	jp la122
;
.game_name
	db "Brainache",0
.game_year
	db "1987",0
.game_publisher
	db "Codemasters",0
.music_author
	db "Jon Paul Eldridge",0
.music_comment
	db " *** Music written and translated by Jon Paul Eldridge (15) *** ",0

	read "music_end_v1_0.asm"
